﻿
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a><cite>首页</cite></a>
        <a><cite>会员管理</cite></a>
        <a><cite>问题/资讯列表</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <fieldset class="table-search-fieldset">
        <legend>搜索信息</legend>
        <div style="margin: 10px 10px 10px 10px">
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="Name" id="Name" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn layui-btn-primary" id="btnSearch" lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
    <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">回复</a>
    </script>

    <div id="page"></div>
</div>
@section Scripts{
    <script>
        layui.use(['laydate', 'laypage', 'layer', 'table','form'], function () {
            $ = layui.jquery;//jquery
            laydate = layui.laydate;//日期插件
            laypage = layui.laypage;//分页
            layer = layui.layer;//弹出层
            table = layui.table;
            form = layui.form;

            $("#btnSearch").click(function () {
                var Name = $("#Name").val();
                //var Phone = $("#Phone").val();
                table.reload("currentTableId", {
                    where: {
                        Name: Name,
                        //Phone: Phone,
                    }
                });
                return false;
            });

            table.render({
                elem: '#currentTableId',
                url: '/admin/Message/List',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    { type: "checkbox", width: 50 },
                    { field: 'id', width: 80, title: 'ID', sort: true },
                    { field: 'name', width: 80, title: '姓名', sort: true },
                    { field: 'tel', width: 80, title: '电话', sort: true },
                    { field: 'email', width: 120, title: '邮箱' },
                    { field: 'cont', title: '内容', minWidth: 120 },
                    { field: 'status', width: 120, title: '状态' },
                    { title: '操作', minWidth: 150, toolbar: '#barDemo', align: "center" }
                ]],
                limits: [5, 10, 15, 20, 25, 50, 100],
                limit: 5,
                page: true,
                skin: 'line'
            });
            table.on('tool(currentTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

                if (layEvent === 'detail') { //查看
                    alert("现在不行哦")
                } else if (layEvent === 'edit') { //编辑
                    //do something

                    //同步更新缓存对应的值
                    layer.open({
                        type: 2,
                        content: '/Admin/Message/Edit?id=' + obj.data.id, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                        area: ['800px', '450px']
                    });
                }
            });
        });


    </script>
}